package cn.bonoon.kernel.web.handlers;

import cn.bonoon.handler.impl.StandardAutoManager;
import cn.bonoon.kernel.support.services.OperateService;
import cn.bonoon.kernel.web.ButtonRefreshType;
import cn.bonoon.kernel.web.controllers.StatusButtonResolver;
/**
 * <pre>
 * 支持通过id来查找对象，并对对象进行相应的操作的处理器
 * 
 * 可能对单个对象或多个对象进行操作
 * 
 * 主要通过ajax的get/post方式提交数据
 * </pre>
 * @author jackson
 *
 * @param <P>
 */
public abstract class AbstractOperateAjaxHandler extends AbstractOperateHandler{
	protected final OperateService operateService;
	private final StandardAutoManager initializer;
	
	protected AbstractOperateAjaxHandler(int operand, OperateService operateService, StandardAutoManager initializer) {
		this(operand, OPERAND_NAMES[operand], operateService, initializer);
	}
	
	protected AbstractOperateAjaxHandler(int operand, String name, OperateService operateService, StandardAutoManager initializer) {
		super(operand, name, initializer);
		this.operateService = operateService;
		this.initializer = initializer;
	}
	
	public StatusButtonResolver register(StatusButtonResolver resolver){
		resolver.setRefreshType(ButtonRefreshType.FINISH);
		initializer.register(this);
		resolver.setUrl(getUrl());
		resolver.setKey(operandCode);
		resolver.setName(operateName);
		return resolver;
	}
}
